/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: 任静
 * @Date: 2020-11-11 19:57:59
 * @LastEditors: 任静
 * @LastEditTime: 2020-11-12 19:07:23
 */
import {getHomeList,getBanner,getHomeContent,getDetail} from '@/api/index'
const state={
    homeList:[],
    bannerList:[],
    articleList:[],
    detailList:[],
    detailTitle:''
}
const mutations={
    updateHomeList(state,payload){
        state.homeList=payload
    },
    updateBanner(state,payload){
        state.bannerList=payload
    },
    
    updateHomeContent(state,payload){
        state.articleList=payload
    },
    updateDetail(state,payload){
        state.detailList=payload.rankDataList
        state.detailTitle=payload.name
    }
}
const actions={
    //首页tab头
    async getHomeList({commit},payload){
        let res=await getHomeList(payload);
        commit("updateHomeList",res.rankCategoryList)
    },
    //首页轮播图
    async getHomeBanner({commit},payload){
        let res=await getBanner(payload);
        commit("updateBanner",res.carouselList)
    },
    //首页视频列表
    async getHomeArticle({commit},payload){
        let res=await getHomeContent(payload);
        commit("updateHomeContent",res.dataList)
    },
    //详情页
    async getDetail({commit},payload){
        let res=await getDetail(payload)
        console.log(res)
        commit("updateDetail",res)
    }
}
export default{
    namespaced: true,
    state,
    mutations,
    actions
}